package org.mags.dao.common;

public class DataAccessException extends RuntimeException {
	private String operation;
	private Class<?> clazz;
	public boolean isReadOperation() {
		if(operation!=null&&
		(operation.contains("QUERY")
		|| operation.contains("GET")))
			return true;
		return false;
	}
	public boolean isCreateOperation() {
		if(operation!=null&&operation.contains("CREATE"))
			return true;
		return false;
	}
	public boolean isUpdateOperation() {
		if(operation!=null&&operation.contains("UPDATE"))
			return true;
		return false;
	}
	public boolean isDeleteOperation() {
		if(operation!=null&&operation.contains("DELETE"))
			return true;
		return false;
	}
	public String getSimpleClassName() {
		return clazz==null?null:clazz.getSimpleName();
	}
	public String getClassName() {
		return clazz==null?null:clazz.getName();
	}
	public Class<?> getClazz() {
		return clazz;
	}
	public String getOperation() {
		return operation;
	}
	public DataAccessException(Class<?> clazz, String operation, Throwable exception) {
		super(exception);
		this.operation = operation;
		this.clazz = clazz;
	}
}
